import router from '@/router'
import axios from 'axios'

const http = axios.create({
  baseURL: 'http://1.92.157.108:8089',
  headers: {
    'Content-Type': 'application/json',
  },
})
export default http
http.interceptors.request.use(
  (config) => {
    const token = localStorage.getItem('Token')
    if (token) {
      config.headers['Authorization'] = `Bearer ${token}`
    } else {
      router.push('/bootPage')
    }
    return config
  },
  (error) => {
    return Promise.reject(error)
  },
)
